# VHost config for {{ app_name }}
{% for item in salt['pillar.get']('vhost:' + app_name, {}) %}
$HTTP["host"] =~ "{{ item["host_header"] }}"  {
    server.document-root = "{{ item["document_root"] }}"

    {% if "rewrite_rule" in item %}
    url.rewrite-once += (
        {% for rewrite_rule in item["rewrite_rule"] -%}
	    "{{ rewrite_rule["regex"] }}" => "{{ rewrite_rule["replacement"] }}",
        {% endfor %}
    )
    {% endif %}

	{% if item["additional_config"] is defined and item["additional_config"] != None %}
    {{ item["additional_config"] | indent(4) }}
    {% endif %}
}

{% endfor %}
